/**
 * Created by maxiaoqiang on 2018/7/5.
 */
import React, {Component} from "react";
import { Table} from 'antd';

class Course extends Component{
    constructor(props){
        super(props);
    }

    thirdRowRender = () => {
        const columns = [
            { title: '章节ID', dataIndex: 'id', key: 'id' },
            { title: '章节名称', dataIndex: 'name', key: 'name' },
            { title: '所占比重', dataIndex: 'percent', key: 'percent' },
            {
                title: '操作',
                dataIndex: 'operation',
                key: 'operation',
                render: () => (
                    <span className="table-operation">
                        <a href="javascript:;">修改</a>&nbsp;&nbsp;<a href="javascript:;">删除</a>
                    </span>
                )
            }
        ];

        const data = [];
        for (let i = 0; i < 3; ++i) {
            data.push({
                key: i,
                id: i+1,
                name: "法律法规",
                percent: 10*(i+1)+"/100"
            });
        }
        return (
            <Table
                showHeader={false}
                columns={columns}
                dataSource={data}
                pagination={false}
            />
        );
    };

    expandedRowRender = () => {
        const columns = [
            { title: '课程ID', dataIndex: 'id', key: 'id' },
            { title: '课程名称', dataIndex: 'name', key: 'name' },
            {
                title: '操作',
                dataIndex: 'operation',
                key: 'operation',
                render: () => (
                    <span className="table-operation">
                        <a href="javascript:;">添加科目</a>
                        &nbsp;&nbsp;<a href="javascript:;">修改</a>
                        &nbsp;&nbsp;<a href="javascript:;">删除</a>
                    </span>
                )
            }
        ];

        const data = [];
        for (let i = 0; i < 3; ++i) {
            data.push({
                key: i,
                id: i+1,
                name: "法律法规"
            });
        }
        return (
            <Table
                showHeader={false}
                columns={columns}
                dataSource={data}
                expandedRowRender={this.thirdRowRender}
                pagination={false}
            />
        );
    };

    render(){
        const columns = [
            { title: '班级ID', dataIndex: 'name', key: 'name' },
            { title: '班级名称', dataIndex: 'platform', key: 'platform' },
            { title: '所属类别', dataIndex: 'version', key: 'version' },
            { title: '学费', dataIndex: 'money', key: 'money' },
            { title: '操作', key: 'operation', render: () => <a href="javascript:;">添加课程</a> },
        ];

        const data = [];
        for (let i = 0; i < 3; ++i) {
            data.push({
                key: i,
                name: i+1,
                platform: '一级建造师',
                version: '工程类',
                money: '4000'
            });
        }
        return (
            <Table
                className="components-table-demo-nested"
                columns={columns}
                expandedRowRender={this.expandedRowRender}
                dataSource={data}
            />
        );
    }
}

export default Course;
